import { req_search_data } from '../../api/req_fun'
import { Message } from 'element-ui'
export default {
    namespaced: true,
    state: () => ({
        search_data: {}
    }),
    actions: {
        async get_search_data({ commit }, req_params) {
            const data = await req_search_data(req_params)
            if (data.code >= 200 && data.code < 300) {
                commit('GET_SEARCH_DATA', data.data)
            } else {
                Message.error('请求错误!')
            }
        }
    },
    mutations: {
        GET_SEARCH_DATA(state, data) {
            state.search_data = data
        }
    },
    getters: {
        attrsList(state) {
            return state.search_data.attrsList || [];
        },
        goodsList(state) {
            return state.search_data.goodsList || [];
        },
        trademarkList(state) {
            return state.search_data.trademarkList || [];
        },
        goods_total(state) {
            return state.search_data.total || 0;
        }
    }
}